package demo03;

import java.util.Random;

public class exercise28 {
	public static void main(String[] args) {
		int arr[] = new int[11];
		Random r = new Random();
		
		for(int i = 0; i<arr.length;i++){
			arr[i]=r.nextInt(100)+1;
		}
		for(int a:arr){
			System.out.print(a+" ");
		}
		/*for(int j=0;j<arr.length-1;j++){
			int max=arr[0];
			int temp=0;
			for(int i=1;i<arr.length;i++){
				if(max>arr[i]){
					temp=arr[i-1];
					arr[i-1]=arr[i];
					arr[i] = temp;
				}else{
					max= arr[i];
				}
			}
		}*/
		for (int j = 0; j < arr.length - 1; j++) {
		    int minIndex = j; 

	
		    for (int i = j + 1; i < arr.length; i++) {
		        if (arr[i] < arr[minIndex]) {
		            minIndex = i;
		        }
		    }

		    int temp = arr[j];
		    arr[j] = arr[minIndex];
		    arr[minIndex] = temp;
		}
		System.out.println();
		for(int a:arr){
			System.out.print(a+" ");
		}
	}
}
